package seventhquestion;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;

public class Server {
    private static List<Thread> threadList = new ArrayList<>();
    public static void main(String[] args) {
        ServerSocket serverSocket = null;
        Socket socket = null;
        try {
            serverSocket = new ServerSocket(8888);
            System.out.println("客户端已经开启。。。。");
            int count=0;
            while (true){
                socket =serverSocket.accept();
                count++;
                System.out.println(socket.getInetAddress()+"\t客户端连接成功,目前在线用户"+count+"个");

                Thread t=new Thread(new ThreadSocket(socket));
                t.start();
                threadList.add(t);

            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
